﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Nirvana
{
    public class WaitLoadAudioClip : CustomYieldInstruction
    {
        private AudioClipCache cache;
        public string Error { get; private set; }
        public AudioClip LoadedObject { get; private set; }
        public WaitLoadAudioClip(AudioClipCache cache)
        {
            this.cache = cache;
        }
        public override bool keepWaiting
        {
            get
            {
                if (!string.IsNullOrEmpty(this.cache.Error))
                {
                    this.Error = this.cache.Error;
                    return false;
                }
                if (this.cache.IsNotNull())
                {
                    this.LoadedObject = this.cache.GetObject();
                    return false;
                }
                return true;
            }
        }
    }
}